<template>
  <div style="padding:3%">
      <el-row>
          <el-col :span="12">
              <el-form :model="form" ref="videoForm" label-width="200px" label-suffix="：">
                <el-form-item v-for="(v,k,i) in form" :label="labels[i]" :key="v.id" :prop="k">
                    <el-select v-if="k=='netGridID'||k=='orgTypeValue'||k=='levelTypeValue'" v-model="form[k]">
                        <template v-if="k=='netGridID'">
                            <el-option v-for="v in netGridType" :key="v.id" :value="v.netGridID" :label="v.netGridName"></el-option>
                        </template>
                        <template v-else-if="k=='orgTypeValue'">
                            <el-option v-for="(v,i) of OrgType" :key="i" :value="v.orgTypeValue" :label="v.orgTypeName"></el-option>
                        </template>
                        <template v-else-if="k=='levelTypeValue'">
                           <el-option v-for="(v,i) of LevelType" :key="i" :value="v.levelTypeValue" :label="v.levelTypeName"></el-option>
                        </template>
                    </el-select>
                    <el-input type="textarea" :max="200" v-else-if="k=='orgBriefIntroduction'||k=='mainFunction'" v-model="form[k]" placeholder="200字以内"></el-input>
                    <el-input-number :min="0" v-else-if="k=='personNumber'" v-model="form[k]"></el-input-number>
                    <el-date-picker v-else-if="k=='orgCreateDate'" v-model="form[k]" placeholder=""></el-date-picker>
                    <el-input v-else v-model="form[k]" style="width:300px"></el-input>
                </el-form-item>
                <el-form-item align="center">
                    <el-button type="warning" @click="reset">重置</el-button>
                    <el-button type="primary" @click="addNewRecord">添加</el-button>
                </el-form-item>
              </el-form>
          </el-col>
      </el-row>
  </div>
</template>

<script>
import * as api from "@/api/zonghezhili/duiwujianshe";
import * as api2 from "@/api/videoManage";
export default {
  data() {
    return {
      num: 4,
      form: {
        orgName:'',//             
        orgTypeValue:'',//         
        levelTypeValue:'',//      
        netGridID:'',//            bigint,
        orgCreateDate:'',//        date,
        orgContactName:'',//       varchar(50) comment '机构联系人姓名',
        orgContactTel:'',//        varchar(20) comment '机构联系电话',
        orgBriefIntroduction:'',// varchar(200),
        businessGuidanceDepartment:'',// varchar(200) comment '业务指导部门',
        personNumber:'',//         int comment '人员数量',
        mainFunction:'',//         varchar(1024) comment '主要职能',
      },
      labels: ["机构名称", "机构类型", "机构级别", "所属网格", "机构创建时间", "机构联系人", "机构联系电话","机构简介","业务指导部门","人员数量","主要职能"],
      netGridType: [],
      OrgType:[],
      LevelType:[],
    };
  },
  methods: {
    reset(){
        for(var key in this.form){
            this.form[key] = ''
        }
    },
    addNewRecord() {
      api.addOrgBasicInfo(this.form).then(res => {
        if (res.data) {
          this.$message({
            type: "success",
            message: "添加成功!"
          });
        } else {
          this.$message({
            type: "error",
            message: res.message
          });
        }
      });
    }
  },
  mounted() {
    api2.fetchNetGrid().then(res => {
      this.netGridType = res.data;
    });
    api.fetchALLTYPEInfo().then(res=>{
        this.OrgType = res.organizationTypes
        this.LevelType = res.levelTypes
    })
  }
};
</script>

<style scoped>

</style>
